package com.drugmanage.controller;


import com.drugmanage.Base.BaseController;
import com.drugmanage.entity.Producer;
import com.drugmanage.model.ResultInfo;
import com.drugmanage.query.ProducerQuery;
import com.drugmanage.service.IProducerService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Map;

@Controller
@RequestMapping("user/producer")
public class ProducerController extends BaseController{
    @Resource
    private IProducerService producerService;

    @RequestMapping("index")
    public String index(){
        return "producer";
    }


    @RequestMapping("queryProducerByParams")
    @ResponseBody
    public Map<String,Object> queryProducerByParams(ProducerQuery producerQuery){
        return producerService.queryForPage(producerQuery);
    }

    @RequestMapping("saveProducer")
    @ResponseBody
    public ResultInfo saveProducer(Producer producer){
        producerService.insertProducer(producer);
        return success("添加成功");
    }
    @RequestMapping("updateProducer")
    @ResponseBody
    public ResultInfo updateProducer(Producer producer){
        producerService.updateProducer(producer);
        return success("修改成功");
    }

    @RequestMapping("deleteProducer")
    @ResponseBody
    public ResultInfo deleteProducer(Integer[] ids){
        producerService.deleteBatchs(ids);
        return success("删除成功");
    }
}
